{!capture name='main'!}
<h1>注册</h1>
<form method="post" action="/action/actor/register" onsubmit="return onSubmit(this)" {!*enctype="multipart/form-data"*!}>
<input type="hidden" name="rurl" value="{!$curUrl!}"/>
<table cellspacing="0" cellpadding="4" border="0" width="100%">
	<tr>
		<td width="60" class="r">Email：</td>
		<td>
			<input type="text" name="email" style="width:200px;" maxlength="50" id="txtEmail"/>
		</td>
	</tr>
	<tr>
		<td></td>
		<td>[ <a href="javascript:void(0);" onclick="$.action('email.exist',document.forms[1]);">检查该邮箱是否可用</a> ]</td>
	</tr>
	<tr>
		<td class="r">昵称：</td>
		<td><input type="text" name="nickname" style="width:200px;" maxlength="20"/><span class="g">你喜爱的称呼，中英文都可以</span></td>
	</tr>
	<tr>
		<td class="r">密  码：</td>
		<td>
			<input type="password" name="password" style="width:200px;" maxlength="20"/><span class="g">6-20位</span>
		</td>
	</tr>
	<tr>
		<td class="r">密码确认：</td>
		<td>
			<input type="password" name="rePassword" style="width:200px;" maxlength="20"/><span class="g">再输一次密码</span>
		</td>
	</tr>
	{!*
	<tr>
		<td class="r">头像：</td>
		<td><input type="file" name="picture" size="40"/><span class="g">不超过2M</span></td>
	</tr>
	*!}
	<tr>
		<td class="r">验证码：</td>
		<td>
			<input type="text" id="txtValidCode" name="validCode" style="width:100px;" maxlength="4" />
			<img style="width:56px;height:20px;display:none;" alt="验证码" id="imgValidCode" align="absmiddle"/>
			&nbsp;<a href="javascript:void(0);" id="lnkReload" style="display:none;" title="点击刷新图片">看不清？</a>
		</td>
	</tr>
	<tr>
		<td></td>
		<td><input type="submit" value="注册"/></td>
	</tr>
</table>
</form>
{!/capture!}
{!capture name='jsCode'!}
<script type="text/javascript" src="/js/action.js"></script>
<script type="text/javascript">
function onSubmit(form){
	if (!/^\w+([-+.']\w+)*@\w+([-.]\w+)*(\.\w+([-.]\w+)*)*$/.test(form.email.value)) {
		alert("Email格式不正确！");
		form.email.focus();
		return false;
	}
	var len = $.trim(form.password.value).length;
	if (len < 6 || len > 20) {
		alert("密码长度为6-20位！");
		form.password.focus();
		return false;
	}
	if (form.rePassword.value != form.password.value) {
		alert("两次输入的密码不一致");
		form.password.focus();
		return false;
	}
	if (!/[\da-zA-Z]{4}/.test($.trim(form.validCode.value))){
		alert("验证码必须为4位的数字或字母");
		form.validCode.focus();
		return false;
	}
	return true;
}
var _init = false;
$('#txtValidCode').focus(function(){
	if (!_init) {
		$('#imgValidCode').css('display','')
			.attr('src','validcode.php?t=' + new Date().getTime());
		$('#lnkReload').css('display','').click(function(){
			loadImage('validcode.php?t=' + new Date().getTime(),function(){
				$('#imgValidCode').attr('src',this.src);
			});
		});
		_init = true;
	}
});
function loadImage(url, callback) {
    var img = new Image();
    img.src = url;
   
    if (img.complete) {
        callback.call(img);
        return;
    }

    img.onload = function () {
        callback.call(img);
    };
};
$('#txtEmail').focus();
</script>
{!/capture!}

{!include file='layouts/default.tpl'!}